<template>
  <div class="uploadimgs">
    <el-upload
      :action="path"
      list-type="picture-card"
      :on-preview="handlePictureCardPreview"
      :on-remove="handleRemove"
      :file-list="getFileList"
      :on-success="upSuccess"
      >
      <i class="el-icon-plus"></i>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>
<script>
export default {

    props:['defaultImgs',"path"],
  components: {},
  name: "",
  data() {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
        fileList:[]
    };
  },
  computed:{
    getFileList(){
        if(!this.defaultImgs)return []
      let res =[]
        this.defaultImgs.forEach(ele => {
            res.push({name:"无",url:ele})

        });
        return res
    },
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    }
    ,
    upSuccess(response, file,fileList){
        let imgs = []
        fileList.forEach(ele=>{
            imgs.push(ele.response.data)
        })
        this.$emit("success",imgs)
    },

  },
  created() {

  }
};
</script>
<style lang="scss" scoped>
.uploadimgs {
}
</style>